﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace GameJamKingdom
{
    class Character
    {
        public Vector2 gridPos;
        public string lastDirection;

        public int timeLastAction;

        public int cMode;
        public List<Mode> modes;

        public Character(Game1 cGame)
        {
            gridPos.X = 3;
            gridPos.Y = 5;
            lastDirection = "right";

            cMode = 0; // start in normal mode
            modes = new List<Mode>();
            modes.Add(new NormalMode(cGame));
            modes.Add(new HammerMode(cGame));
            modes.Add(new WaterMode(cGame));

            timeLastAction = 0;
        }

        public Mode getMode()
        {
            return modes[cMode];
        }

        public void right()
        {
            gridPos.X++;
            timeLastAction = 0;
            lastDirection = "right";
        }

        public void left()
        {
            gridPos.X--;
            timeLastAction = 0;
            lastDirection = "left";
        }

        public void up()
        {
            gridPos.Y--;
            timeLastAction = 0;
            lastDirection = "up";
        }

        public void down()
        {
            gridPos.Y++;
            timeLastAction = 0;
            lastDirection = "down";
        }

        public void update(GameTime cTime)
        {

        }

        public void render(SpriteBatch spriteBatch, int offset)
        {
            Texture2D art;
            switch (lastDirection)
            {
                case "left":
                    art = modes[cMode].artLeft;
                    break;
                case "right":
                    art = modes[cMode].artRight;
                    break;
                case "up":
                    art = modes[cMode].artUp;
                    break;
                case "down":
                    art = modes[cMode].artDown;
                    break;
                default:
                    art = modes[cMode].artLeft;
                    break;
            }

            spriteBatch.Draw(art, new Rectangle(-(offset % 50) + ((int)gridPos.X * 50), 50 * ((int)gridPos.Y + 1), 50, 50), Color.White);
        }
    }
}
